function res = TP1T(outfilename)
	outfile = fopen(outfilename, 'w');
	digitos = [2, 4, 6, 8];
	terminos = 20;
	printskip = 5;
	res = [];
	fprintf(outfile, '\\begin{tabular}{|c|%s}\\hline\n D\\''igitos ', repmat('l|l|', 1, floor(terminos/printskip)));
	for t = printskip:printskip:terminos
		fprintf(outfile, '& $T_{%d}$ & $\\vert e_{%d} \\vert$ ', t, t);
	end;
	fprintf(outfile, ' \\\\\\hline\n');
	for t = digitos
		fprintf(outfile, '$%d$', t);
		rest.x = taylor(t, terminos);
		rest.d = abs(sqrt(2) - rest.x);
		rest.e = abs(rest.d ./ rest.x);
		for j = printskip:printskip:terminos
			if (mod(j, printskip) == 0)
				fprintf(outfile, sprintf('\t &$%%.%df$\t& $%%f$',
						max(0, t-ceil(log10(rest.x(j))))),
					rest.x(j), rest.e(j));
			end;
		end;
		fprintf(outfile, ' \\\\\\hline\n');
		res = [res; rest];
	end;
	fprintf(outfile, '\\end{tabular}\n');
	figure();
	semilogy(1:terminos, res(1).d, '-x;d=2;',
		1:terminos, res(2).d, '-x;d=4;',
		1:terminos, res(3).d, '-x;d=6;',
		1:terminos, res(4).d, '-x;d=8;');
	xlabel('Terminos');
	ylabel('|d|');
	print('tex/erroresT.png');
end;

function ret = taylor(t, n)
	gr = grillaCorta(t);
	x = 11/8;
	ret = [3/2; 11/8];
	productoria = 1;
	for k=3:n
		productoria = gr(productoria * (gr(gr(2 * (k - 2)) + 1)));
		x = gr(x + gr(gr(gr(power(-1, k - 1))/gr(pow2(k)))*
				gr(productoria/gr(factorial(k)))));
		ret = [ret; x];
	end;
end;

